<?php
/**
 * Base_App
 *
 * LICENSE
 *
 * This source file is subject to the new CC-GNU LGPL
 * It is available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/LGPL/2.1/
 *
 * @category   Base_App
 * @copyright  Copyright (c) 2009 Alexander fanatique* Thomas (me@alexander-thomas.net)
 * @license    http://creativecommons.org/licenses/LGPL/2.1/
 */
class Base_App_Controller_Cli
{
	protected $params;
	
	/**
	 * Contructor stores the Cli parameters
	 *
	 * @param array $params 
	 * @author Alexander Thomas
	 */
	function __construct(array $params){
		$this->params = $params;
	}
	
	/**
	 * Try to execute the requested method
	 * @throws Base_App_Cli_Exception
	 * @return void
	 * @author Alexander Thomas
	 */
	public function run(){
		$methodName = $this->params[0]."Action";
		if(method_exists($this, $methodName) === true){
			$this->$methodName();			
		}else{
			$message = "\"".$this->params[0] . "\" is not a valid action in \"" . get_class($this) . "\" controller.";
			throw new Base_App_Cli_Exception($message);
		}
	}
}

?>
